package com.ruoyi.deal.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.deal.service.ICcsComplaintService;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.deal.domain.CcsComplaint;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 投诉 Controller
 *
 * @author zzh
 * @date 2024-10-17
 */
@RestController
@RequestMapping("/system/complaint")
@Api(tags = "投诉")
public class CcsComplaintController extends BaseController
{
    @Autowired
    private ICcsComplaintService ccsComplaintService;

    /**
     * 查询投诉列表
     */
    @PreAuthorize("@ss.hasPermi('system:complaint:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcsComplaint ccsComplaint)
    {
        startPage();
        List<CcsComplaint> list = ccsComplaintService.selectCcsComplaintList(ccsComplaint);
        return getDataTable(list);
    }

    /**
     * 导出投诉列表
     */
    @PreAuthorize("@ss.hasPermi('system:complaint:export')")
    @Log(title = "投诉", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcsComplaint ccsComplaint)
    {
        List<CcsComplaint> list = ccsComplaintService.selectCcsComplaintList(ccsComplaint);
        ExcelUtil<CcsComplaint> util = new ExcelUtil<CcsComplaint>(CcsComplaint.class);
        util.exportExcel(response, list, "投诉数据");
    }

    /**
     * 获取投诉详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:complaint:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ccsComplaintService.selectCcsComplaintById(id));
    }

    /**
     * 新增投诉
     */
    @PreAuthorize("@ss.hasPermi('system:complaint:add')")
    @Log(title = "投诉", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcsComplaint ccsComplaint)
    {
        return toAjax(ccsComplaintService.insertCcsComplaint(ccsComplaint));
    }

    /**
     * 修改投诉
     */
    @PreAuthorize("@ss.hasPermi('system:complaint:edit')")
    @Log(title = "投诉", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcsComplaint ccsComplaint)
    {
        return toAjax(ccsComplaintService.updateCcsComplaint(ccsComplaint));
    }

    /**
     * 删除投诉
     */
    @PreAuthorize("@ss.hasPermi('system:complaint:remove')")
    @Log(title = "投诉", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccsComplaintService.deleteCcsComplaintByIds(ids));
    }
}
